package com.cskaoyan.gateway.controller.user;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.user.IVerifyService;
import com.mall.user.annotation.Anoymous;
import com.mall.user.constants.SysRetCodeConstants;
import com.mall.user.dto.UserVerifyRequest;
import com.mall.user.dto.UserVerifyResponse;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author：Chunk
 * @Description: 用户激活控制中心
 * @Date Created in 16:38 2021/4/21
 */
@RestController
@RequestMapping("/user")
public class VerifyController {
    @Reference(timeout = 3000,check = false)
    IVerifyService verifyService;

    @GetMapping("/verify")
    @Anoymous
    public ResponseData verify(String uid, String username){
        //更行用户表和用户验证表
        UserVerifyRequest userVerifyRequest = new UserVerifyRequest();
        userVerifyRequest.setUserName(username);
        userVerifyRequest.setUuid(uid);
        UserVerifyResponse verify = verifyService.verify(userVerifyRequest);
        if(verify.getCode().equals(SysRetCodeConstants.SUCCESS.getCode())){
            return new ResponseUtil<>().setData(null);
        }
        return new ResponseUtil<>().setErrorMsg(verify.getMsg());
    }
}
